package com.example.popupsample;

import com.example.popupsample.component.InputPopup;
import com.example.popupsample.component.dto.InputPopupDto;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends Activity {

	private InputPopup mInputPopup = null;
	private InputPopup.UserActionListener mInputPopupListener = new InputPopup.UserActionListener() {
		
		@Override
		public void onInputText(String text) {
			if(text != null) {
				Toast.makeText(MainActivity.this, text, Toast.LENGTH_LONG);
			}
			mInputPopup.dismiss();
		}
	};
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		Button bt = ((Button)this.findViewById(R.id.btInputBox));
		bt.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				InputPopupDto dto = new InputPopupDto(null, "input something!!");
				mInputPopup = new InputPopup(MainActivity.this, dto);
				mInputPopup.setUserActionListener(mInputPopupListener);
				mInputPopup.show();
			}
		});
	}

}
